﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Library;
using System.IO;
using System.Collections;
using System.Data.SqlClient;
using System.Threading;
namespace QuanLyThi
{
    public partial class FrmXemMauDeThi : Form
    {
        public static string mConnect = FrmMain.mConnect;
        private string msql = "";
        public DGC_Library mLibrary = new DGC_Library(mConnect);

        int ID = 0;
        public FrmXemMauDeThi(int ID)
        {
            InitializeComponent();
            this.ID = ID;
            this.LOAD();
        }
     
       

        private void LoadNoidung(RichTextBox rt, byte[] noidung)
        {
            Stream theFile = new MemoryStream(noidung);
            rt.LoadFile(theFile, RichTextBoxStreamType.RichText);
        }

     
        private void list_SelectionChanged(object sender, EventArgs e)
        {
           
        }
       
        public static byte[] StrToByteArray(string str)
        {
            System.Text.UTF8Encoding encoding = new System.Text.UTF8Encoding();
            return encoding.GetBytes(str);
        }
     
      
       
        private Boolean InsertUpdateData(SqlCommand cmd)
        {
            SqlConnection con = new SqlConnection(mConnect);
            cmd.CommandType = CommandType.Text;
            cmd.Connection = con;
            try
            {
                con.Open();
                cmd.ExecuteNonQuery();
                return true;
            }
            catch (Exception)
            {
                return false;
            }
            finally
            {
                con.Close();
                con.Dispose();
            }
        }


        void LOAD()
        {
            msql = "SELECT*  FROM [dbo].[MauDeThi] " +
                             " WHERE ID=" + ID;
            DataTable dtH = mLibrary.GetDataTable(msql, "a");
            LoadNoidung(rtHeader, (byte[])dtH.Rows[0]["NoiDungHeader"]);
            LoadNoidung(rtFooter, (byte[])dtH.Rows[0]["NoiDungFooter"]);
        }
     
       
      
     

       





















       

       
      


    

    }
}
